package com.xintonghua.bussiness.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by zhangxuemei on 2018/3/11.
 */

public class DateUtils {


    public static String getCurrentDate() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        Date curDate = new Date(System.currentTimeMillis());
        return formatter.format(curDate);
    }

    public static String getDateBeforeYear() {
        Calendar calendar = Calendar.getInstance();
        String year = calendar.get(Calendar.YEAR) - 1 + "";
        String month = calendar.get(Calendar.MONTH) + 1 + "";
        String day = calendar.get(Calendar.DAY_OF_MONTH) + "";
        String hour = calendar.get(Calendar.HOUR_OF_DAY) + "";
        String minute = calendar.get(Calendar.MINUTE) + "";
//        String second = calendar.get(Calendar.SECOND) + "";
        return  year +"-"+ month +"-"+ day +" "+ hour +":"+ minute;
    }

    public static String getDateAfterYear() {
        Calendar calendar = Calendar.getInstance();
        String year = calendar.get(Calendar.YEAR) + 1 + "";
        String month = calendar.get(Calendar.MONTH) + 1 + "";
        String day = calendar.get(Calendar.DAY_OF_MONTH) + "";
        String hour = calendar.get(Calendar.HOUR_OF_DAY) + "";
        String minute = calendar.get(Calendar.MINUTE) + "";
//        String second = calendar.get(Calendar.SECOND) + "";
        return  year +"-"+ month +"-"+ day +" "+ hour +":"+ minute;
    }
}
